<?php

namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;

class MaterialController extends AuthController
{
    public $currentHeader = 'header-operation';

    public function actionList() {
        return $this->show();
    }

    public function actionNewMaterial() {
        return $this->show();
    }

    public function actionNewMaterialHandle() {
        $response = Yii::$app->response;
        $response->format = Response::FORMAT_JSON;
        $response->data = [
            'status' => 'success',
            'msg' => '保存成功！'
        ];
        return $response;
    }

    public function actionMaterialEdit() {
        return $this->show();
    }

    public function actionMaterialEditHandle() {
        $response = Yii::$app->response;
        $response->format = Response::FORMAT_JSON;
        $response->data = [
            'status' => 'success',
            'msg' => '保存成功！'
        ];
        return $response;
    }

    public function actionGetAllMaterials() {
        $materials = $this->service->getAllMaterials();
        $this->jsonReturn(['data'=> $materials]);
    }
}// end
